package com.neusoft.NEPS.common;

import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.URL;

public class FXMLUtils {
    public static void switchTo(Node node,String fxmlPath) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = FXMLUtils.class.getResource("../view/"+fxmlPath);
        fxmlLoader.setLocation(url);
        Scene scene = node.getScene();
        scene.setRoot(fxmlLoader.load());
    }
    public static void switchToShow(Node node,String fxmlPath) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = FXMLUtils.class.getResource("../view/"+fxmlPath);
        fxmlLoader.setLocation(url);
        Scene scene = node.getScene();
        scene.setRoot(fxmlLoader.load());
        Stage stage = (Stage)scene.getWindow();
        stage.setScene(scene);
        stage.show();
    }
}
